package com.shengqin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shengqin.common.pojo.CommonPage;
import com.shengqin.entity.TotalScoreStandard;
import com.shengqin.mapper.TotalScoreStandardMapper;
import com.shengqin.service.ITotalScoreStandardService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TotalScoreStandardServiceImpl extends ServiceImpl<TotalScoreStandardMapper, TotalScoreStandard> implements ITotalScoreStandardService {
    @Override
    public List<TotalScoreStandard> listByTemplateId(Integer templateId) {
        QueryWrapper<TotalScoreStandard> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(TotalScoreStandard::getTemplateId,templateId);
        wrapper.lambda().orderByDesc(TotalScoreStandard::getScore);
        return list(wrapper);
    }

    @Override
    public Page<TotalScoreStandard> queryTotalStandardPage(CommonPage<TotalScoreStandard> commonPage) {
        TotalScoreStandard query = commonPage.getQueryParam();
        QueryWrapper<TotalScoreStandard> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(TotalScoreStandard::getTemplateId,query.getTemplateId());
        wrapper.lambda().orderByDesc(TotalScoreStandard::getScore);
        Page<TotalScoreStandard> standardPage = new Page<>(commonPage.getPageNo(),commonPage.getPageSize());
        page(standardPage,wrapper);
        return standardPage;
    }
}
